# Tmux settings

# Set shell, mouse
set-option -g default-shell /bin/zsh
set -g mouse on

# Set colors
# set -g default-terminal "xterm-256color"
set -g default-terminal "screen-256color"
# set-option -ga terminal-overrides ",xterm-256color:Tc"

# Set XTerm key bindings
setw -g xterm-keys on

# Set Ctrl-b key bindings 把ctrl-b重定义为'`'
unbind C-b
set -g prefix `

# Set reload key to r
bind r source-file ~/.tmux.conf \; display-message "tmux.conf reloaded..."

# Count sessions start at 1
set -g base-index 1

# Use vim bindings
setw -g mode-keys vi

# start selecting text typing 'v' key (once you are in copy mode)
bind-key -T copy-mode-vi 'v' send -X begin-selection
# # copy selected text to the system's clipboard
bind-key -T copy-mode-vi 'y' send -X copy-pipe-and-cancel pbcopy

#up
bind-key k select-pane -U
#down
bind-key j select-pane -D
#left
bind-key h select-pane -L
#right
bind-key l select-pane -R

# split window
unbind '"'
bind h splitw -v
unbind %
bind v splitw -h

# resize pane
bind -r ^k resizep -U 10 # upward (prefix Ctrl+k)
bind -r ^j resizep -D 10 # downward (prefix Ctrl+j)
bind -r ^h resizep -L 10 # to the left (prefix Ctrl+h)
bind -r ^l resizep -R 10 # to the right (prefix Ctrl+l)

# Status bar settings
# alignment
set-option -g status-justify centre

# left-bottom corner
set-option -g status-left '#[bg=black,fg=green][#[fg=cyan]#S#[fg=green]]'
set-option -g status-left-length 20

# window list
setw -g automatic-rename on
set-window-option -g window-status-format '#[dim]#I:#[default]#W#[fg=grey,dim]'
set-window-option -g window-status-current-format '#[fg=cyan,bold]#I#[fg=blue]:#[fg=cyan]#W#[fg=dim]'

# right-bottom status
set -g status-right '#[fg=green][#[fg=cyan]%Y-%m-%d#[fg=green]]'

# center window status
set -g window-status-format "#I:#W"
set -g window-status-current-format "#I:#W*"

# default statusbar colors
set -g status-fg white
set -g status-bg black

# default window title colors
# set-window-option -g window-status-fg white
# set-window-option -g window-status-bg default
# set-window-option -g window-status-attr dim

# active window title colors
# set-window-option -g window-status-current-fg red
# set-window-option -g window-status-current-bg default
# set-window-option -g window-status-current-attr bold

# command/message line colors
# set -g message-fg white
# set -g message-bg black
# set -g message-attr bright

set -g status-keys vi
bind-key -T vi-edit Up send -X history-up
bind-key -T vi-edit Down send -X history-down

set -g status-interval 1
set -g status-justify centre # center align window list

# window-name
set-option -g allow-rename off

# tmux_resurrect
run-shell ~/.vim/tmux-resurrect/resurrect.tmux

